package com.wcy.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.wcy.annotation.pageVo.PageColumn;
import com.wcy.annotation.pageVo.PageName;
import com.wcy.annotation.pageVo.SelectionAnnotation;
import lombok.*;
import lombok.experimental.Accessors;

import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 
 * </p>
 *
 * @author 吴传亿
 * @since 2025-04-28
 */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@TableName("user_role")
@Accessors(chain = true)
@PageName(name = "用户角色")
public class UserRole {
    @PageColumn(prop="userId", label="用户ID",type = "select",selectRef = @SelectionAnnotation(apiUrl = "user/list",mapProp = "userId",mapLabel = "username"))
    private Integer userId;

    @PageColumn(prop="roleId", label="角色ID",type = "select",selectRef = @SelectionAnnotation(apiUrl = "role/list",mapProp = "roleId",mapLabel = "roleName"))
    private Integer roleId;

    public UserRole(Integer roleId){
        this.roleId = roleId;
    }

    public UserRole(Map<String, Object> map){
        this.userId = (Integer) map.get("userId");
        this.roleId = (Integer) map.get("roleId");
    }
}
